<?php include TMPL_PATH.'public/header.phtml';?>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/jscal2.css"/>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/border-radius.css"/>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/win2k.css"/>
<script type="text/javascript" src="/statics/js/calendar/calendar.js"></script>
<script type="text/javascript" src="/statics/js/calendar/lang/zh-cn.js"></script>
<script type="text/javascript" src="/statics/js/ichart/ichart.1.2.min.js"></script>
<style type="text/css">
</style>
<title></title>
		<script type="text/javascript">
			$(function(){
				//var flow=[];
				//var ip=[];
/*				for(var i=0;i<50;i++){
					flow.push(Math.floor(Math.random()*(30+((i%12)*5)))+10);
					ip.push(Math.floor(Math.random()*(30+((i%12)*5)))+10);
				}*/
				<?php
				    $scale_space = 300;
				    $end_scale = 3000;
				    $scale_space2 = 5;
				    $end_scale2 = 30;					
				    $pay_amount = 'var pay_amount=[';
					$order_num    = 'var order_num=[';
					$labels       = 'var labels=[';
				    foreach($orderOneRes as $val){
					    $pay_amount .= "'".$val['pay_amount']."',";
						$order_num    .= "'".$val['order_num']."',";
						$labels       .= "'".$val['labels']."',";
						
						if($val['pay_amount'] > $end_scale){
							if($val['pay_amount']/$scale_space > 20){
							    $scale_space = ($val['pay_amount']/20);
								$scale_space = $scale_space > 1000 ? ceil($scale_space/1000)*1000 : ceil($scale_space/100)*100;
							}
						    $end_scale = $val['pay_amount'] + $scale_space*2;
						}
						
						if($val['order_num'] > $end_scale2){
							if($val['order_num']/$scale_space2 > 20){
							    $scale_space2 = ($val['order_num']/20);
								$scale_space2 = $scale_space2 > 100 ? ceil($scale_space2/100)*100 : ceil($scale_space2/10)*10;
							}
						    $end_scale2 = $val['order_num'] + $scale_space2*2;
						}					
						
					}
					echo $pay_amount = substr($pay_amount, 0, -1).'];';
					echo $order_num    = substr($order_num, 0, -1).'];';
					echo $labels       = substr($labels, 0, -1).'];';
					
					echo 'var end_scale = '.$end_scale.';';
					echo 'var scale_space = '.$scale_space.';';
					echo 'var end_scale2 = '.$end_scale2.';';
					echo 'var scale_space2 = '.$scale_space2.';';					
				?>
				
				var data = [
				         	{
				         		name : '金额',
				         		value:pay_amount,
				         		color:'#0d8ecf',
				         		line_width:2
				         	}
							];
				var data2 = [			
							{
				         		name : '订单数量',
				         		value:order_num,
				         		color:'#f68f70',
				         		line_width:2
				         	}
				         ];
		         
				//var labels = ["2012-12-01","2012-12-02","2012-12-03","2012-12-04","2012-12-05","2012-12-06"];
				
				var showHtml = '';
				if($('#order_status').val() != 9999){
				    showHtml += $('#order_status').find("option:selected").text();
				} 
				if($('#payment_status').val() != 9999){
				    showHtml += $('#payment_status').find("option:selected").text();
				} 
				if($('#shipping_status').val() != 9999){
				    showHtml += $('#shipping_status').find("option:selected").text();
				} 
				if($('#time_type').val() != 9999){
				    showHtml += $('#time_type').find("option:selected").text();
				}
				showHtml += $('#start_time').val();
				showHtml += '~';
				showHtml += $('#end_time').val();
																
				var line = new iChart.LineBasic2D({
					render : 'canvasDiv',
					data: data,
					align:'center',
					title : 'OWNONLY订单金额(单位：USD)',
					subtitle : '['+showHtml+'](总支付金额：'+<?php echo $orderAllRes['pay_amount'] ? $orderAllRes['pay_amount']: 0;?>+')',
					footnote : '数据来源：订单数据',
					width : 1500,
					height : 400,
					sub_option:{
						//label:false,
						smooth : true,//平滑曲线
						point_size:10
					},
		            animation : true,//开启过渡动画
				    animation_duration:600,//600ms完成动画					
					tip:{
						enable:true,
						shadow:true,
						listeners:{
							 //tip:提示框对象、name:数据名称、value:数据值、text:当前文本、i:数据点的索引
							parseText:function(tip,name,value,text,i){
								return "<span style='color:#005268;font-size:12px;'>"+labels[i]+"<br/>"+
								"</span><span style='color:#005268;font-size:14px;'>订单支付金额:"+pay_amount[i]+"<br/>订单数量:"+order_num[i]+"</span>";
							}
						}
					},
					legend : {
						enable : false
					},
					crosshair:{
						enable:true,
						line_color:'#62bce9'
					},
					coordinate:{
						width:1200,
						valid_width:1180,
						height:400,
						axis:{
							color:'#9f9f9f',
							width:[0,0,2,2]
						},
						grids:{
							vertical:{
								way:'share_alike',
						 		value:12
							}
						},
						scale:[{
							 position:'left',	
							 start_scale:0,
							 end_scale:end_scale,
							 scale_space:scale_space,
							 scale_size:2,
							 scale_color:'#9f9f9f'
						},{
							 position:'bottom',	
							 labels:labels
						}]
					}
				});
			//开始画图
			line.draw();
			var line2 = new iChart.LineBasic2D({
					render : 'canvasDiv2',
					data: data2,
					align:'center',
					title : 'OWNONLY订单数量',
					subtitle : '['+showHtml+'](总数量：'+<?php echo $orderAllRes['order_num'] ? $orderAllRes['order_num']: 0;?>+')',
					footnote : '数据来源：订单数据',
					width : 1500,
					height : 400,
					sub_option:{
						smooth : true,//平滑曲线
						point_size:10
					},
		            animation : true,//开启过渡动画
				    animation_duration:600,//600ms完成动画						
					tip:{
						enable:true,
						shadow:true,
						listeners:{
							 //tip:提示框对象、name:数据名称、value:数据值、text:当前文本、i:数据点的索引
							parseText:function(tip,name,value,text,i){
								return "<span style='color:#005268;font-size:12px;'>"+labels[i]+"<br/>"+
								"</span><span style='color:#005268;font-size:14px;'>订单支付金额:"+pay_amount[i]+"<br/>订单数量:"+order_num[i]+"</span>";
							}
						}
					},
					legend : {
						enable : false
					},
					crosshair:{
						enable:true,
						line_color:'#62bce9'
					},
					coordinate:{
						width:1200,
						valid_width:1180,
						height:400,
						axis:{
							color:'#9f9f9f',
							width:[0,0,2,2]
						},
						grids:{
							vertical:{
								way:'share_alike',
						 		value:12
							}
						},
						scale:[{
							 position:'left',	
							 start_scale:0,
						     end_scale:end_scale2,
							 scale_space:scale_space2,
							 scale_size:2,
							 scale_color:'#9f9f9f'
						},{
							 position:'bottom',	
							 labels:labels
						}]
					}
				});
			//开始画图
			line2.draw();
			
		});
				
			</script>
<div class="subnav">
    <div class="content-menu ib-a blue">
    	<div style="color:#000;">
			<div style="float:left;">
    		<form name="searchform" action="<?php echo U('order/order_count');?>"  method="post">
    		<input type="hidden" value="1" name="search">
			<input type="hidden" value="<?php echo $pageRows; ?>" name="pageRows">
    		订单状态：<select name="order_status" id="order_status">
    		<option value='9999' <?php if(9999==$order_status)echo 'selected';?>>≡ 全部  ≡</option>
				<?php foreach (OrderModel::$orderStatusCn as $status_key => $status_name):?>
				<option value='<?php echo $status_key?>' <?php if($status_key==$order_status)echo 'selected';?>><?php echo $status_name;?></option>
				<?php endforeach;?>
			  </select>
              &nbsp;&nbsp;&nbsp;付款状态：<select name="payment_status" id="payment_status">
				 	<option value='9999' <?php if(9999==$payment_status)echo 'selected';?>>≡ 全部  ≡</option>
				 	<?php foreach (OrderModel::$paymentStatus as $status_key => $status_name):?>
				<option value='<?php echo $status_key?>' <?php if(!is_null($payment_status) && $status_key==$payment_status)echo 'selected';?>><?php echo $status_name;?></option>
				<?php endforeach;?>
				 </select>
                 &nbsp;&nbsp;&nbsp;配送状态：<select name="shipping_status" id="shipping_status">
				 	<option value='9999' <?php if(9999==$shipping_status)echo 'selected';?>>≡ 全部  ≡</option>
				 	<?php foreach (OrderModel::$shippingStatus as $status_key => $status_name):?>
				<option value='<?php echo $status_key?>' <?php if(!is_null($shipping_status) && $status_key==$shipping_status)echo 'selected';?>><?php echo $status_name;?></option>
				<?php endforeach;?>
				 </select>
                 <br /><br />
                筛选时间：<select name="time_type" id="time_type">
                    <option value='0' <?php if(0==$time_type)echo 'selected';?>>支付时间</option>
				 	<option value='1' <?php if(1==$time_type)echo 'selected';?>>下单时间</option>
				 </select>
                                                   
                &nbsp;&nbsp;&nbsp;开始时间:
                <input class="input-text" name="start_time" type="text" id="start_time" size="22" value='<?php echo $start_time;?>'/>
                <script type="text/javascript">
                    Calendar.setup({
                    weekNumbers: true,
                    inputField : "start_time",
                    trigger    : "start_time",
                    dateFormat: "%Y-%m-%d",
                    showTime: false,
                    minuteStep: 1,
                    onSelect   : function() {this.hide();}
                    });
                </script>
                &nbsp;&nbsp;&nbsp;结束时间:
                <input class="input-text"  name="end_time" type="text" id="end_time" size="22" value='<?php echo $end_time;?>'/>
                <script type="text/javascript">
                    Calendar.setup({
                    weekNumbers: true,
                    inputField : "end_time",
                    trigger    : "end_time",
                    dateFormat: "%Y-%m-%d",
                    showTime: false,
                    minuteStep: 1,
                    onSelect   : function() {this.hide();}
                    });
                </script>
                 &nbsp;&nbsp;&nbsp;日期分段：<select name="date_type" id="data_type">
				 	<option value='day'   <?php if('day'  ==$date_type)echo 'selected';?>>日</option>
                    <option value='week'  <?php if('week' ==$date_type)echo 'selected';?>>周</option>
                    <option value='month' <?php if('month'==$date_type)echo 'selected';?>>月</option>
                    <option value='year'  <?php if('year' ==$date_type)echo 'selected';?>>年</option>
				 </select>                
      		&nbsp;&nbsp;&nbsp;<input type="submit" value="查询" class="button" name="time_search">
    		</form>
			</div>
    	</div>
    </div>
</div>
<div class="bk"></div>
<div class="pad_10">
<div class="table-list">
<table width="100%" cellspacing="0" >
<thead>
    <tr>
    <th width="100%"></th>
    </tr>
</thead>
</table>
<div id='canvasDiv'></div>
<div id='canvasDiv2'></div>
</div>
</div>
</body>
</html>
<script type="text/javascript">
</script>
